package polymorphic;

public class test2 {
    public static void drawShapes() {
// 我们创建一个 Shape 对象的数组.

    }
    public static void main(String[] args) {
        Cycle cycle = new Cycle();
        Rect rect = new Rect();
        Flower flower = new Flower();
        String[] arr = {"cycle", "rect", "rect", "flower"};   //假如要打印这些图画
        for (String row : arr) {
            if (row.equals("cycle")) {
                cycle.draw();
            }
            if (row.equals("rect")) {
                rect.draw();
            }
            if (row.equals("flower")) {
                flower.draw();
            }
        }
//        public static void main(String[] args) {
//            Shape[] shapes = {new Cycle(), new Rect(), new Rect(), new Flower()};
//            for (Shape shape : shapes) {
//                shape.draw();
//            }
//        }
    }
}

class Shape {
    public void draw() {
        System.out.println("画一个画");
    }
}

class Cycle extends Shape {
    public void draw() {
        System.out.println("○");
    }
}

class Rect extends Shape {
    public void draw() {
        System.out.println("◇");
    }
}

class Flower extends Shape {
    public void draw() {
        System.out.println("❀");
    }
}
